package thirdwork.controller;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import thirdwork.dao.EmployeeDao;
import thirdwork.dao.UserDao;
import thirdwork.dao.impl.EmployeeImpl;
import thirdwork.dao.impl.UserImpl;
import thirdwork.domain.Employee;
import thirdwork.domain.User;

/**
 * Servlet implementation class ShowEmployee
 */
@WebServlet("/ShowEmployee")
public class ShowEmployee extends HttpServlet {
	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		req.setCharacterEncoding("UTF-8");
		resp.setContentType("text/html;charset=UTF-8");
		resp.setCharacterEncoding("UTF-8");
		EmployeeDao empdao = new EmployeeImpl();
		List<Employee> lists = empdao.selectAll();
		for (int i = 0; i < lists.size(); i++) {
			System.out.println(lists.get(i));
		}
		HttpSession session = req.getSession();
		session.setAttribute("lists", lists);
		resp.sendRedirect(req.getContextPath() + "/showEmployee.jsp");
	}
}
